<p>This is an issue when using <code>Array#includes()</code> to check if a value exists in an array that is used primarily for existence checking and
is checked multiple times.</p>
<h2>Why is this an issue?</h2>
<p>Using <code>Array#includes()</code> for existence checks can lead to performance problems, especially with larger datasets.</p>
<p><code>Array#includes()</code> has O(n) time complexity because it needs to iterate through the array elements until it finds a match or reaches the
end. In contrast, <code>Set#has()</code> has O(1) average time complexity because it uses a hash table internally.</p>
<p>For small arrays (typically under 10-20 elements), the performance difference is negligible. However, as the array size grows, the performance gap
becomes significant. For an array with 1000 elements, <code>Array#includes()</code> might need to check up to 1000 elements, while
<code>Set#has()</code> performs the check almost instantly.</p>
<p>This performance difference becomes even more pronounced when the existence check is performed multiple times, such as in loops or frequently
called functions.</p>
<h3>What is the potential impact?</h3>
<p>Performance degradation can occur when checking existence in large arrays, especially when these checks are performed frequently. This can lead to
slower application response times and poor user experience in performance-critical code paths.</p>
<h3>How to fix?</h3>
<p>Replace the array with a Set when the primary use case is existence checking. Convert the array to a Set using the Set constructor, then use
<code>Set#has()</code> instead of <code>Array#includes()</code>.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const allowedValues = [1, 2, 3, 4, 5];
const isAllowed = value =&gt; allowedValues.includes(value); // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const allowedValues = new Set([1, 2, 3, 4, 5]);
const isAllowed = value =&gt; allowedValues.has(value);
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-set-has.md">prefer-set-has</a> </li>
  <li> MDN - Set.prototype.has() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has">Documentation
  for the Set.has() method</a> </li>
  <li> MDN - Array.prototype.includes() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes">Documentation for the Array.includes()
  method</a> </li>
  <li> MDN - Set - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set">Complete documentation for the Set
  object</a> </li>
</ul>
